     AddCSLuaFile( "cl_init.lua" )
     AddCSLuaFile( "shared.lua" )
      
     include('shared.lua')
	 
	 function ENT:SpawnFunction( ply, tr)
		local SpawnPos = tr.HitPos + Vector( 0, 0, 15) 
		local ent = ents.Create( "colonies_headcrabegg" )
		ent:SetPos( SpawnPos )
		ent:Spawn()
		return ent
	end

      
    function ENT:Initialize()
		
		self.Entity:SetModel("models/props_junk/PopCan01a.mdl")
		self.Entity:PhysicsInit( SOLID_VPHYSICS ) // Make us work with physics,
		self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) // after all, gmod is a physics
		self.Entity:SetSolid( SOLID_VPHYSICS ) // Toolbox 
		self.Entity:GetPhysicsObject():Wake()
		self.Entity:SetMaterial("models/debug/debugwhite")
		
		self.laid = math.Round(CurTime())
		self.Species = "normal"
		
    end
     
     function ENT:OnTakeDamage(dmg)
    
     end

	function ENT:FormGenetics()
	heady:SetNetworkedBool("FromEgg", true)

	

		//Get previous genetics
		//self.Entity:GetNetworkedString
	end	
	    
	/*---------------------------------------------------------
	Name: OnRemove
	Desc: Called just before entity is deleted
	//-------------------------------------------------------*/
	function ENT:OnRemove()

	end
  
 	function ENT:Think()
		if math.Round(CurTime()) > self.laid + GetConVarNumber("co_headcrab_eggtime") then
		local heady = ents.Create("colonies_headcrab")			
		local mutationchance = 2

			if headcrabCount() < GetConVarNumber("co_headcrab_max") then
		local eggtype = math.random(1,100)
		if eggtype <= mutationchance then 
		heady = ents.Create("colonies_headcrabfast")
		self.Species = "fast"
		elseif eggtype > mutationchance && eggtype < (mutationchance * 2) then 
		heady = ents.Create("colonies_headcrabpoison")
		self.Species = "poison"
		elseif eggtype >= (mutationchance * 2) then 
		heady = ents.Create("colonies_headcrab")
		self.Species = "normal"
		end
				undo.ReplaceEntity(self.Entity,heady)
		
				heady:SetPos(self.Entity:GetPos()+Vector(0,0,15))
				self.Entity:FormGenetics()				

				heady:Spawn()
			end
			
			self.Entity:Remove()
		
		end
	end 